<?php

class SkypeStatus extends CWidget {

  public $nickname;

  public function run() {
    $basePath = Yii::app()->baseUrl . '/images/';
    $status = @file_get_contents('http://mystatus.skype.com/' . $this->nickname. '.num');
    
    if ($status == 2) //online
      $imageSrc = $basePath . 'skype_online.png';
    else //offline
      $imageSrc = $basePath . 'skype_offline.png';
    
    $image = CHtml::image($imageSrc, $this->nickname, array(
      'style' => 'width: 125px',
    ));
    
    $skypeLink = 'skype:' . $this->nickname . '?chat';
    echo CHtml::link($image, $skypeLink);
  }

}
